#! /usr/bin/python

""" This script will plot the pickled data returned from cli_lfp_weighed average"""

import sys
import cPickle

import pylab


from projects.electrophysiology.view_data import frame_utils

fraction = 0.75
pickle_filename = sys.argv[1]
for arg in sys.argv[1:]:
    if 'fraction=' in arg:
        fraction = arg.split('=')[1] 

print "reading in the cpickle file %s" % pickle_filename

with open(pickle_filename, 'r') as infile:
    result_dict = cPickle.load(infile)

# get the image
image = result_dict['results']
# normalize the image
norm_image = frame_utils.saturating_linear_norm(image, fraction)
#color compose the image
pylab.figure()
pylab.title('Whatever title you want')
axes = pylab.subplot(111)
frame_utils.color_compose([norm_image],['black'],
                          axes,bg='white',invert_alpha=True)
pylab.show()
